package com.foreknow.oop10;

import javax.jnlp.IntegrationService;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * Set接口，它是一个无序的集合
 * 实现类：HashSet   TreeSet:可以有排序的功能
 * 面试题：Set和List的父接口 Collection
 */
public class SetDemo {
  public static void main(String[] args) {
    Set<Person> set = new HashSet<>();
    Person p1 = new Person();
    p1.setId("1000");
    p1.setName("tom");
    p1.setAge(30);
    Person p2 = new Person();
    p2.setId("1002");
    p2.setName("tom2");
    p2.setAge(32);
    set.add(p1);
    set.add(p2);


    Iterator<Person> iterator = set.iterator();
    while (iterator.hasNext()){
      Person pp = iterator.next();
      System.out.println(pp.getName());
    }


  }
}
